package com.parking.mgr.common.exception;

import com.parking.mgr.common.pojo.response.Result;

/**
 * @ClassName BaseException
 * @Description 基础异常
 * @author: zhijianpu
 * @Date: 2025/2/28
 */
public abstract class BaseException extends RuntimeException {

    public static final Integer DEFAULT_CODE = Result.DEFAULT_ERROR_CODE;
    protected Integer code;
    protected String message;

    public BaseException(String message) {
        super(String.format("code=%s, errorMessage=%s", DEFAULT_CODE, message));
        this.code = DEFAULT_CODE;
        this.message = message;
    }

    public BaseException(Integer code, String message) {
        super(String.format("code=%s, errorMessage=%s", code, message));
        this.code = code;
        this.message = message;
    }

    public BaseException(Throwable cause, Integer code, String message) {
        super(String.format("code=%s, errorMessage=%s", code, message), cause);
        this.code = code;
        this.message = message;
    }


    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

}
